# 通用函数

def load_class(class_path, class_name, request):
    try:
        # 加载模块
        pkg_main = __import__(class_path)
        # 迭代加载对应的class
        split_pkg = class_path.split('.')
        for p in split_pkg:
            pkg_main = getattr(pkg_main, p)
        pkg_main = getattr(pkg_main, class_name)
        get_class = pkg_main(request)
        return get_class
    except Exception as e:
        print(e)
        return None
